﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using BesAsm.MasterData.Entities;
using BesAsm.MasterData.Data;

#endregion

namespace BesAsm.MasterData.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="FixedFloorElevationProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class FixedFloorElevationProviderBaseCore : EntityProviderBase<BesAsm.MasterData.Entities.FixedFloorElevation, BesAsm.MasterData.Entities.FixedFloorElevationKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, BesAsm.MasterData.Entities.FixedFloorElevationKey key)
		{
			return Delete(transactionManager, key.FfeId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_ffeId">Primary key, FFE Id. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _ffeId)
		{
			return Delete(null, _ffeId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_ffeId">Primary key, FFE Id. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _ffeId);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_DSCS key.
		///		FK_FIXED_FLOOR_ELEVATIONS_DSCS Description: 
		/// </summary>
		/// <param name="_dscId">DSC Id</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByDscId(System.Int32? _dscId)
		{
			int count = -1;
			return GetByDscId(_dscId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_DSCS key.
		///		FK_FIXED_FLOOR_ELEVATIONS_DSCS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_dscId">DSC Id</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		/// <remarks></remarks>
		public TList<FixedFloorElevation> GetByDscId(TransactionManager transactionManager, System.Int32? _dscId)
		{
			int count = -1;
			return GetByDscId(transactionManager, _dscId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_DSCS key.
		///		FK_FIXED_FLOOR_ELEVATIONS_DSCS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_dscId">DSC Id</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByDscId(TransactionManager transactionManager, System.Int32? _dscId, int start, int pageLength)
		{
			int count = -1;
			return GetByDscId(transactionManager, _dscId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_DSCS key.
		///		fkFixedFloorElevationsDscs Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_dscId">DSC Id</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByDscId(System.Int32? _dscId, int start, int pageLength)
		{
			int count =  -1;
			return GetByDscId(null, _dscId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_DSCS key.
		///		fkFixedFloorElevationsDscs Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_dscId">DSC Id</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByDscId(System.Int32? _dscId, int start, int pageLength,out int count)
		{
			return GetByDscId(null, _dscId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_DSCS key.
		///		FK_FIXED_FLOOR_ELEVATIONS_DSCS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_dscId">DSC Id</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public abstract TList<FixedFloorElevation> GetByDscId(TransactionManager transactionManager, System.Int32? _dscId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_STATUSES key.
		///		FK_FIXED_FLOOR_ELEVATIONS_STATUSES Description: 
		/// </summary>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByStatus(System.String _status)
		{
			int count = -1;
			return GetByStatus(_status, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_STATUSES key.
		///		FK_FIXED_FLOOR_ELEVATIONS_STATUSES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		/// <remarks></remarks>
		public TList<FixedFloorElevation> GetByStatus(TransactionManager transactionManager, System.String _status)
		{
			int count = -1;
			return GetByStatus(transactionManager, _status, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_STATUSES key.
		///		FK_FIXED_FLOOR_ELEVATIONS_STATUSES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByStatus(TransactionManager transactionManager, System.String _status, int start, int pageLength)
		{
			int count = -1;
			return GetByStatus(transactionManager, _status, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_STATUSES key.
		///		fkFixedFloorElevationsStatuses Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByStatus(System.String _status, int start, int pageLength)
		{
			int count =  -1;
			return GetByStatus(null, _status, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_STATUSES key.
		///		fkFixedFloorElevationsStatuses Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public TList<FixedFloorElevation> GetByStatus(System.String _status, int start, int pageLength,out int count)
		{
			return GetByStatus(null, _status, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_FIXED_FLOOR_ELEVATIONS_STATUSES key.
		///		FK_FIXED_FLOOR_ELEVATIONS_STATUSES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.FixedFloorElevation objects.</returns>
		public abstract TList<FixedFloorElevation> GetByStatus(TransactionManager transactionManager, System.String _status, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override BesAsm.MasterData.Entities.FixedFloorElevation Get(TransactionManager transactionManager, BesAsm.MasterData.Entities.FixedFloorElevationKey key, int start, int pageLength)
		{
			return GetByFfeId(transactionManager, key.FfeId, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_FIXED_FLOOR_ELEVATIONS index.
		/// </summary>
		/// <param name="_ffeId">Primary key, FFE Id</param>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> class.</returns>
		public BesAsm.MasterData.Entities.FixedFloorElevation GetByFfeId(System.Int32 _ffeId)
		{
			int count = -1;
			return GetByFfeId(null,_ffeId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_FIXED_FLOOR_ELEVATIONS index.
		/// </summary>
		/// <param name="_ffeId">Primary key, FFE Id</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> class.</returns>
		public BesAsm.MasterData.Entities.FixedFloorElevation GetByFfeId(System.Int32 _ffeId, int start, int pageLength)
		{
			int count = -1;
			return GetByFfeId(null, _ffeId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_FIXED_FLOOR_ELEVATIONS index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_ffeId">Primary key, FFE Id</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> class.</returns>
		public BesAsm.MasterData.Entities.FixedFloorElevation GetByFfeId(TransactionManager transactionManager, System.Int32 _ffeId)
		{
			int count = -1;
			return GetByFfeId(transactionManager, _ffeId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_FIXED_FLOOR_ELEVATIONS index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_ffeId">Primary key, FFE Id</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> class.</returns>
		public BesAsm.MasterData.Entities.FixedFloorElevation GetByFfeId(TransactionManager transactionManager, System.Int32 _ffeId, int start, int pageLength)
		{
			int count = -1;
			return GetByFfeId(transactionManager, _ffeId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_FIXED_FLOOR_ELEVATIONS index.
		/// </summary>
		/// <param name="_ffeId">Primary key, FFE Id</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> class.</returns>
		public BesAsm.MasterData.Entities.FixedFloorElevation GetByFfeId(System.Int32 _ffeId, int start, int pageLength, out int count)
		{
			return GetByFfeId(null, _ffeId, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_FIXED_FLOOR_ELEVATIONS index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_ffeId">Primary key, FFE Id</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> class.</returns>
		public abstract BesAsm.MasterData.Entities.FixedFloorElevation GetByFfeId(TransactionManager transactionManager, System.Int32 _ffeId, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;FixedFloorElevation&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;FixedFloorElevation&gt;"/></returns>
		public static TList<FixedFloorElevation> Fill(IDataReader reader, TList<FixedFloorElevation> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				BesAsm.MasterData.Entities.FixedFloorElevation c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("FixedFloorElevation")
					.Append("|").Append((System.Int32)reader[((int)FixedFloorElevationColumn.FfeId - 1)]).ToString();
					c = EntityManager.LocateOrCreate<FixedFloorElevation>(
					key.ToString(), // EntityTrackingKey
					"FixedFloorElevation",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new BesAsm.MasterData.Entities.FixedFloorElevation();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.FfeId = (System.Int32)reader[((int)FixedFloorElevationColumn.FfeId - 1)];
					c.OriginalFfeId = c.FfeId;
					c.DscId = (reader.IsDBNull(((int)FixedFloorElevationColumn.DscId - 1)))?null:(System.Int32?)reader[((int)FixedFloorElevationColumn.DscId - 1)];
					c.Address = (reader.IsDBNull(((int)FixedFloorElevationColumn.Address - 1)))?null:(System.String)reader[((int)FixedFloorElevationColumn.Address - 1)];
					c.Rno = (reader.IsDBNull(((int)FixedFloorElevationColumn.Rno - 1)))?null:(System.String)reader[((int)FixedFloorElevationColumn.Rno - 1)];
					c.FixedFloorElevation = (reader.IsDBNull(((int)FixedFloorElevationColumn.FixedFloorElevation - 1)))?null:(System.Decimal?)reader[((int)FixedFloorElevationColumn.FixedFloorElevation - 1)];
					c.HasNoBasement = (reader.IsDBNull(((int)FixedFloorElevationColumn.HasNoBasement - 1)))?null:(System.Int32?)reader[((int)FixedFloorElevationColumn.HasNoBasement - 1)];
					c.SurveyDate = (reader.IsDBNull(((int)FixedFloorElevationColumn.SurveyDate - 1)))?null:(System.DateTime?)reader[((int)FixedFloorElevationColumn.SurveyDate - 1)];
					c.Comment = (reader.IsDBNull(((int)FixedFloorElevationColumn.Comment - 1)))?null:(System.String)reader[((int)FixedFloorElevationColumn.Comment - 1)];
					c.EditedBy = (System.String)reader[((int)FixedFloorElevationColumn.EditedBy - 1)];
					c.EditReason = (System.String)reader[((int)FixedFloorElevationColumn.EditReason - 1)];
					c.Status = (System.String)reader[((int)FixedFloorElevationColumn.Status - 1)];
					c.AppendDate = (System.DateTime)reader[((int)FixedFloorElevationColumn.AppendDate - 1)];
					c.EditDate = (reader.IsDBNull(((int)FixedFloorElevationColumn.EditDate - 1)))?null:(System.DateTime?)reader[((int)FixedFloorElevationColumn.EditDate - 1)];
					c.DscidDeprecated = (reader.IsDBNull(((int)FixedFloorElevationColumn.DscidDeprecated - 1)))?null:(System.Int32?)reader[((int)FixedFloorElevationColumn.DscidDeprecated - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, BesAsm.MasterData.Entities.FixedFloorElevation entity)
		{
			if (!reader.Read()) return;
			
			entity.FfeId = (System.Int32)reader[((int)FixedFloorElevationColumn.FfeId - 1)];
			entity.OriginalFfeId = (System.Int32)reader["ffe_id"];
			entity.DscId = (reader.IsDBNull(((int)FixedFloorElevationColumn.DscId - 1)))?null:(System.Int32?)reader[((int)FixedFloorElevationColumn.DscId - 1)];
			entity.Address = (reader.IsDBNull(((int)FixedFloorElevationColumn.Address - 1)))?null:(System.String)reader[((int)FixedFloorElevationColumn.Address - 1)];
			entity.Rno = (reader.IsDBNull(((int)FixedFloorElevationColumn.Rno - 1)))?null:(System.String)reader[((int)FixedFloorElevationColumn.Rno - 1)];
			entity.FixedFloorElevation = (reader.IsDBNull(((int)FixedFloorElevationColumn.FixedFloorElevation - 1)))?null:(System.Decimal?)reader[((int)FixedFloorElevationColumn.FixedFloorElevation - 1)];
			entity.HasNoBasement = (reader.IsDBNull(((int)FixedFloorElevationColumn.HasNoBasement - 1)))?null:(System.Int32?)reader[((int)FixedFloorElevationColumn.HasNoBasement - 1)];
			entity.SurveyDate = (reader.IsDBNull(((int)FixedFloorElevationColumn.SurveyDate - 1)))?null:(System.DateTime?)reader[((int)FixedFloorElevationColumn.SurveyDate - 1)];
			entity.Comment = (reader.IsDBNull(((int)FixedFloorElevationColumn.Comment - 1)))?null:(System.String)reader[((int)FixedFloorElevationColumn.Comment - 1)];
			entity.EditedBy = (System.String)reader[((int)FixedFloorElevationColumn.EditedBy - 1)];
			entity.EditReason = (System.String)reader[((int)FixedFloorElevationColumn.EditReason - 1)];
			entity.Status = (System.String)reader[((int)FixedFloorElevationColumn.Status - 1)];
			entity.AppendDate = (System.DateTime)reader[((int)FixedFloorElevationColumn.AppendDate - 1)];
			entity.EditDate = (reader.IsDBNull(((int)FixedFloorElevationColumn.EditDate - 1)))?null:(System.DateTime?)reader[((int)FixedFloorElevationColumn.EditDate - 1)];
			entity.DscidDeprecated = (reader.IsDBNull(((int)FixedFloorElevationColumn.DscidDeprecated - 1)))?null:(System.Int32?)reader[((int)FixedFloorElevationColumn.DscidDeprecated - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, BesAsm.MasterData.Entities.FixedFloorElevation entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.FfeId = (System.Int32)dataRow["ffe_id"];
			entity.OriginalFfeId = (System.Int32)dataRow["ffe_id"];
			entity.DscId = Convert.IsDBNull(dataRow["dsc_id"]) ? null : (System.Int32?)dataRow["dsc_id"];
			entity.Address = Convert.IsDBNull(dataRow["address"]) ? null : (System.String)dataRow["address"];
			entity.Rno = Convert.IsDBNull(dataRow["rno"]) ? null : (System.String)dataRow["rno"];
			entity.FixedFloorElevation = Convert.IsDBNull(dataRow["fixed_floor_elevation"]) ? null : (System.Decimal?)dataRow["fixed_floor_elevation"];
			entity.HasNoBasement = Convert.IsDBNull(dataRow["has_no_basement"]) ? null : (System.Int32?)dataRow["has_no_basement"];
			entity.SurveyDate = Convert.IsDBNull(dataRow["survey_date"]) ? null : (System.DateTime?)dataRow["survey_date"];
			entity.Comment = Convert.IsDBNull(dataRow["comment"]) ? null : (System.String)dataRow["comment"];
			entity.EditedBy = (System.String)dataRow["edited_by"];
			entity.EditReason = (System.String)dataRow["edit_reason"];
			entity.Status = (System.String)dataRow["status"];
			entity.AppendDate = (System.DateTime)dataRow["append_date"];
			entity.EditDate = Convert.IsDBNull(dataRow["edit_date"]) ? null : (System.DateTime?)dataRow["edit_date"];
			entity.DscidDeprecated = Convert.IsDBNull(dataRow["dscid_deprecated"]) ? null : (System.Int32?)dataRow["dscid_deprecated"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="BesAsm.MasterData.Entities.FixedFloorElevation"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">BesAsm.MasterData.Entities.FixedFloorElevation Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, BesAsm.MasterData.Entities.FixedFloorElevation entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region DscIdSource	
			if (CanDeepLoad(entity, "Dsc|DscIdSource", deepLoadType, innerList) 
				&& entity.DscIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = (entity.DscId ?? (int)0);
				Dsc tmpEntity = EntityManager.LocateEntity<Dsc>(EntityLocator.ConstructKeyFromPkItems(typeof(Dsc), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.DscIdSource = tmpEntity;
				else
					entity.DscIdSource = DataRepository.DscProvider.GetByDscId(transactionManager, (entity.DscId ?? (int)0));		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'DscIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.DscIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.DscProvider.DeepLoad(transactionManager, entity.DscIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion DscIdSource

			#region StatusSource	
			if (CanDeepLoad(entity, "Status|StatusSource", deepLoadType, innerList) 
				&& entity.StatusSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.Status;
				Status tmpEntity = EntityManager.LocateEntity<Status>(EntityLocator.ConstructKeyFromPkItems(typeof(Status), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.StatusSource = tmpEntity;
				else
					entity.StatusSource = DataRepository.StatusProvider.GetByStatusId(transactionManager, entity.Status);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'StatusSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.StatusSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.StatusProvider.DeepLoad(transactionManager, entity.StatusSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion StatusSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the BesAsm.MasterData.Entities.FixedFloorElevation object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">BesAsm.MasterData.Entities.FixedFloorElevation instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">BesAsm.MasterData.Entities.FixedFloorElevation Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, BesAsm.MasterData.Entities.FixedFloorElevation entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region DscIdSource
			if (CanDeepSave(entity, "Dsc|DscIdSource", deepSaveType, innerList) 
				&& entity.DscIdSource != null)
			{
				DataRepository.DscProvider.Save(transactionManager, entity.DscIdSource);
				entity.DscId = entity.DscIdSource.DscId;
			}
			#endregion 
			
			#region StatusSource
			if (CanDeepSave(entity, "Status|StatusSource", deepSaveType, innerList) 
				&& entity.StatusSource != null)
			{
				DataRepository.StatusProvider.Save(transactionManager, entity.StatusSource);
				entity.Status = entity.StatusSource.StatusId;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region FixedFloorElevationChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>BesAsm.MasterData.Entities.FixedFloorElevation</c>
	///</summary>
	public enum FixedFloorElevationChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>Dsc</c> at DscIdSource
		///</summary>
		[ChildEntityType(typeof(Dsc))]
		Dsc,
			
		///<summary>
		/// Composite Property for <c>Status</c> at StatusSource
		///</summary>
		[ChildEntityType(typeof(Status))]
		Status,
		}
	
	#endregion FixedFloorElevationChildEntityTypes
	
	#region FixedFloorElevationFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;FixedFloorElevationColumn&gt;"/> class
	/// that is used exclusively with a <see cref="FixedFloorElevation"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class FixedFloorElevationFilterBuilder : SqlFilterBuilder<FixedFloorElevationColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationFilterBuilder class.
		/// </summary>
		public FixedFloorElevationFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public FixedFloorElevationFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public FixedFloorElevationFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion FixedFloorElevationFilterBuilder
	
	#region FixedFloorElevationParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;FixedFloorElevationColumn&gt;"/> class
	/// that is used exclusively with a <see cref="FixedFloorElevation"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class FixedFloorElevationParameterBuilder : ParameterizedSqlFilterBuilder<FixedFloorElevationColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationParameterBuilder class.
		/// </summary>
		public FixedFloorElevationParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public FixedFloorElevationParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public FixedFloorElevationParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion FixedFloorElevationParameterBuilder
	
	#region FixedFloorElevationSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;FixedFloorElevationColumn&gt;"/> class
	/// that is used exclusively with a <see cref="FixedFloorElevation"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class FixedFloorElevationSortBuilder : SqlSortBuilder<FixedFloorElevationColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the FixedFloorElevationSqlSortBuilder class.
		/// </summary>
		public FixedFloorElevationSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion FixedFloorElevationSortBuilder
	
} // end namespace
